<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.control.UserControl"%>
<%@ page import="com.control.CalcuControl"%>
<%@ page import="com.model.User"%>
<%@ page import="com.model.*"%>
<%@ page import="com.util.*"%>
<%@ page import="com.util.PageResultSet"%>
<%@ page import="java.io.FileInputStream"%>
<%@ page import="java.io.IOException"%>
<%@ page import="java.io.FileOutputStream"%>
<%@ page import="java.io.InputStream"%>
<%@ page import="java.io.FileNotFoundException"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>成绩显示</title>
	</head>
	<body>
		<%
		List<GoodStudentModel> exportExcel = new ArrayList<GoodStudentModel>();
		CalcuControl cc = new CalcuControl();
		exportExcel = cc.getGoodStudent();
		String[] headers = new String[]{"学号","平均分"};
		FileOutputStream out1 = null ;
		ExportExcel<GoodStudentModel>  exportForExcel = new ExportExcel<GoodStudentModel>();
		try {
			out1 = new FileOutputStream("C:\\goodStudent.xls");
			exportForExcel.exportExcel("优秀学生名单",headers,exportExcel,  out1, "yyyy-MM-dd");
			System.out.println("EXCEL导出成功!");  
			String fileName = "goodStudent".toString();
			InputStream inStream = new FileInputStream("C:/goodStudent.xls");
	//		HttpServletResponse response = ServletActionContext.getResponse();
			response.reset();
			response.setContentType("bin");
			response.addHeader("Content-Disposition", "attachment;filename="+fileName);
			byte[] b = new byte[10];
			int len;
			try {
				while((len=inStream.read(b))>0)
					//response.getOutputStream().write(b, 0, len);
					inStream.close();
			} catch (IOException e) {
				 //TODO Auto-generated catch block
				e.printStackTrace();
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{  
			   if(null != out1){  
				      try {  
				            out1.close();  
				      } catch (IOException e) {  
				                    e.printStackTrace();  
				      }  
		       }
			   
		}
		 %>
	</body>
</html>
